import {Todo} from "@/types/Todo";

//封装保存数据的hook函数工具类
export const saveTodos = (todos:Todo[]) => {
    localStorage.setItem('todos_key', JSON.stringify(todos))
}

export const readTodos = ():Todo[] => {
    //读取数据默认为空数组
    console.log(JSON.parse(localStorage.getItem('todos_key') || '[]'))
    return JSON.parse(localStorage.getItem('todos_key') || '[]')
}
